<template>
  <div class="search">
    <a-drawer :visible="modalVisible"  width="1000" @close="handleClose">
    <a-tabs @tabClick="handleTabClick" :defaultActiveKey="current" v-model="current">
        <a-tab-pane tab="项目部门权限" key="form1">
          <dept-project ref="form1" v-if="modalVisible"></dept-project>
        </a-tab-pane>
      </a-tabs>
    <div class="drawer-footer">
      <a-button type="default" @click="handleClose">取消</a-button>&nbsp;
      <a-button type="primary" @click="handleSubmit" :loading="saving">保存</a-button>
    </div>
    </a-drawer>
  </div>
</template>

<script>
  import deptProject from './dept_project.vue'
    export default {
      name: 'projectdept',
      props: {},
      data() {
        return {
          saving: false,
          modalVisible: false,
          isEdit: false,
          title: '',
          current: 'form1',
          formData: {},
          forms: [
            'form1'
          ]
        }
      },
      methods: {
        handleShow(data) {
          this.isEdit = false
          this.userName = ''
          if (data && data.projectId) {
            this.isEdit = true
            this.formData = data
          } else {
            this.formData = {}
          }
          this.modalVisible = true
          this.handleTabClick('form1')
        },
        handleClose() {
          this.modalVisible = false
        },
        handleSubmit() {
          this.$refs[this.current].handleSubmit(this.handleClose)
        },
        handleTabClick(name) {
          this.current = name
          if (this.current === this.forms[0]) {
            this.title = this.isEdit ? '编辑项目部门权限 - ' : '添加用户'
          }
          this.$nextTick(() => {
            this.$refs[this.current].setData(this.formData)
          })
        }
      },
      computed: {
        modalTitle: function() {
          return this.title + this.userName
        }
      },
      created() {
      },
      components: { deptProject }
    }
</script>

<style scoped lang="less" rel="stylesheet/less">

</style>